﻿using System.ComponentModel;
using System.Windows.Forms;
using HogoLogic;

namespace ProjectView
{
	public class ProjectSelector : Component
	{
		private ProjectViewForm dialogForm;

		public HogoProject SelectProject(HogoProjectList projects)
		{
			dialogForm = new ProjectViewForm(projects);
			if (dialogForm.ShowDialog() == DialogResult.OK)
			{
				if (dialogForm.Result == SelectProjectResult.Open)
					return dialogForm.SelectedProject;
				else
				{
					projects.Projects.Add(dialogForm.NewProject);
					return dialogForm.NewProject;
				}
			}
			else 
				return null;
		}
	}
}
